cmake_minimum_required(VERSION 3.14)

include(cmake/prelude.cmake)

project(
    cpp-make-everything
    VERSION 0.1.0
    DESCRIPTION "Short description"
    HOMEPAGE_URL "https://example.com/"
    LANGUAGES CXX
)

include(cmake/project-is-top-level.cmake)
include(cmake/variables.cmake)

# ---- Declare executable ----

add_executable(cpp-make-everything_exe source/main.cpp)
add_executable(cpp-make-everything::exe ALIAS cpp-make-everything_exe)

set_property(TARGET cpp-make-everything_exe PROPERTY OUTPUT_NAME cpp-make-everything)

target_compile_features(cpp-make-everything_exe PRIVATE cxx_std_20)

# ---- Add subdirectories for each executable ----
file(GLOB source_dirs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/source" "${CMAKE_CURRENT_SOURCE_DIR}/source/*")
foreach(dir ${source_dirs})
    if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/source/${dir}")
        add_subdirectory("source/${dir}")
    endif()
endforeach()

# ---- Install rules ----

if(NOT CMAKE_SKIP_INSTALL_RULES)
  include(cmake/install-rules.cmake)
endif()

# ---- Developer mode ----

if(NOT cpp-make-everything_DEVELOPER_MODE)
  return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
  message(
      AUTHOR_WARNING
      "Developer mode is intended for developers of cpp-make-everything"
  )
endif()

include(cmake/dev-mode.cmake)
